home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / Pascal / Snippets / PNL Libraries / Libraries / NewFader 2.0 / NewFader.p < prev    next >
Text File  |  1997-04-16  |  5KB  |  176 lines

  1. {----------------------------------------------------------------------}
  2. {The Gamma Fading history :}
  3. {}
  4. {On 12/17/92 ,Matt Slot ,fprefec@engin.umich.edu, wrote a C program for performing}
  5. {gamma fading on the Macintosh.}
  6. {}
  7. {Matt last updated that program 6/29/95 to release v1.1.3.}
  8. {}
  9. {On 7/20/93, Matthew Xavier Mora, mxmora@mxmdesigns.com, made a library using the }
  10. {Gamma C code, and wrote a Think Pascal program which sampled the use of that library }
  11. {(including some pascal routines for delaying the fade).}
  12. {}
  13. {In a separate endeavor in 1994, Ingemar Ragnemalm also created a library based upon the }
  14. {C code, added some separate fade in and fade out routines in Pascal, and got a pascal }
  15. {program running the gamma fader in Think Pascal. In July of 95 he updated his project}
  16. {to use Matt's v1.1.3 gamma routines, and added a CW project as well.}
  17. {}
  18. {Happy with having an available gamma fader, us Pascal programmers were still not quite }
  19. {_satisfied_ being that the library was still C-coded.}
  20. {}
  21. {So on 7/13/95, Matthew Mora ported the entire C-code over to Pascal, and got it }
  22. {debugged and running on 7/18/95 in Think Pascal.}
  23. {}
  24. {Ecstatic over the whole thing, on 7/18/95, Bill Catambay created CW projects in }
  25. {68K and PPC demonstrating the Gamma Fading using _pure_ pascal (incorporating }
  26. {Matthew's ported library routines, his older delay routines, tuning for CW, and }
  27. {cleaning the code a bit).}
  28. {}
  29. {07/23/95: Changes by Ingemar R:}
  30. {• Added a Think Pascal lib and added the necessary conditional compilation switches to make it run in both worlds.}
  31. {• Cleaned up the capitalization a bit (to conform with Inside Mac).}
  32. {• Centered the window on the screen.}
  33. {• Modified the picture: now 2k instead of 80k, and easier to edit in the future.}
  34. {I made NO changes in the fading unit except the IFC in the uses clause.}
  35. {}
  36. {05/08/96: Updates by Ingemar R:}
  37. {• CW7 projects. (Not CW8, but at least better than CW5 or 6.)}
  38. {• Changed PBControl and PBStatus to PBControlSync and PBStatusSync.}
  39. {}
  40. {Files in project:}
  41. {}
  42. {NewFader.p  -  This test program for performing a slow fade out, a fast fade in, and}
  43. {                then a fast fade out and a slow fade in.}
  44. {GammaPaslib.p  -  The gamma routines and internal type declarations, all in PASCAL.}
  45. {NewFader.µ.rsrc  -  Resource for About picture.}
  46. {NewFader(68K).µ  -  The 68K CW project for the gamma fading program.}
  47. {NewFader(PPC).µ  -  The PPC CW project for the gamma fading program.}
  48. {NewFader.π - Think Pascal project (added by Ingemar)}
  49. {}
  50. {Works like a charm!}
  51. {}
  52. {Bill Catambay, catambay@aol.com}
  53. {----------------------------------------------------------------------}
  54. program DoubleFade;
  55.  
  56.     uses
  57. {$IFC UNDEFINED THINK_PASCAL}
  58.         ToolUtils, Fonts, SegLoad, Dialogs, Processes, Types, Windows, Quickdraw, OSUtils, 
  59.         Menus, TextEdit, Memory, Events, 
  60. {$ENDC}
  61.         GammaPaslib;
  62.  
  63.     var
  64.         oe: integer;
  65.         delayTime: Longint;
  66.         myRect, bounds: Rect;
  67.         myWindow: WindowPtr;
  68.         myPicture: PicHandle;
  69.  
  70.     procedure DelayFadeToBlack (delayTicks: Longint);
  71.  
  72.         var
  73.             i: integer;
  74.             oe: integer;
  75.             finalTicks: Longint;
  76.  
  77.     begin
  78.         i := 100;
  79.         while i > 0 do
  80.             begin
  81.                 oe := DoGammaFade(i);
  82.                 i := i - 1;
  83.                 Delay(delayTicks, finalTicks);
  84.             end;
  85.     end; {DelayFadeToBlack}
  86.  
  87.     procedure FadeToBlack (speed: integer);
  88.  
  89.         var
  90.             i: integer;
  91.             oe: integer;
  92.  
  93.     begin
  94.         i := 100;
  95.         while (i >= 0) do
  96.             begin
  97.                 oe := DoGammaFade(i);
  98.                 i := i - speed;
  99.             end;
  100.     end; {FadeToBlack}
  101.  
  102.     procedure FadeFromBlack (speed: integer);
  103.  
  104.         var
  105.             i: integer;
  106.             oe: integer;
  107.  
  108.     begin
  109.         i := 0;
  110.         while (i <= 100) do
  111.             begin
  112.                 oe := DoGammaFade(i);
  113.                 i := i + speed;
  114.             end;
  115.     end; {FadeFromBlack}
  116.  
  117.     procedure DelayFadeFromBlack (delayTicks: Longint);
  118.  
  119.         var
  120.             i: integer;
  121.             oe: integer;
  122.             finalTicks: Longint;
  123.  
  124.     begin
  125.         i := 0;
  126.         while (i <= 100) do
  127.             begin
  128.                 oe := DoGammaFade(i);
  129.                 i := i + 1;
  130.                 Delay(delayTicks, finalTicks);
  131.             end;
  132.     end; {DelayFadeFromBlack}
  133.  
  134.     procedure ToolboxInit;
  135.  
  136.     begin
  137. {$IFC UNDEFINED THINK_PASCAL}
  138.         InitGraf(@qd.thePort);
  139.         InitFonts;
  140.         InitWindows;
  141.         InitMenus;
  142.         TEinit;
  143.         InitDialogs(nil);
  144. {$ENDC}
  145.         MaxApplZone;
  146.         InitCursor;
  147.     end; {ToolboxInit}
  148.  
  149. begin {Main program}
  150.     ToolboxInit;
  151.     delayTime := 1;
  152.     if not isGammaAvailable then
  153.         ExitToShell;
  154.     oe := SetupGammaTools;
  155. {Center the picture's bounds on the screen}
  156. {$IFC UNDEFINED THINK_PASCAL}
  157.     bounds := qd.screenBits.bounds;
  158. {$ELSEC}
  159.     bounds := screenBits.bounds;
  160. {$ENDC}
  161.     myPicture := GetPicture(128);
  162.     myRect := myPicture^^.picFrame;
  163.     OffsetRect(myRect, (bounds.right - bounds.left - myRect.right - myRect.left) div 2, (bounds.bottom - bounds.top - myRect.bottom - myRect.top) div 2);
  164. {Fade and then create the window}
  165.     DelayFadeToBlack(delaytime);
  166.     myWindow := NewCWindow(nil, myRect, '', TRUE, plainDBox, Pointer(-1), FALSE, 0);
  167.     SetPort(myWindow);
  168.     DrawPicture(myPicture, myWindow^.portRect);
  169.     FadeFromBlack(2);
  170.     repeat
  171.     until Button;
  172.     FadeToBlack(2);
  173.     HideWindow(mywindow);
  174.     DelayFadeFromBlack(delaytime);
  175.     oe := DisposeGammaTools;
  176. end.